

package;
import Facebook; 
import php.Lib;

      class Sample
      {
			public var facebook:Facebook;
			
			public static inline var APPURL 	 = "http://apps.facebook.com/YOUR_APP_NAME/";			
			public static inline var APPID       = "YOUR_APP_ID";
			public static inline var SECRET 	 = "YOUR_APP_SECRET_KEY";
			public static inline var COOKIE      = true;
			
      		static function main()
      		{
      			new Sample();
      		}
      		public function new()
      		{  
				var params:Hash<Dynamic> = new Hash();
				params.set('appId', APPID);
				params.set('secret', SECRET);
				params.set('cookie', COOKIE);
				
				facebook = FB.init(params, APPURL);	 
				
				if(facebook!=null)
				{
					Lib.print("<h1>FB.getCurrentUser()</h1><p>Get the current user profile.</p>");
					var currentUser = FB.getCurrentUser();
					var currentUID = FB.getCurrentUID();
					 
					Lib.print("<h3>You :</h3>");
					Lib.print("<img src='https://graph.facebook.com/"+currentUID+"/picture'> <br/> "+currentUser.get('name'));  
					
					Lib.print("<h1>FB.getUser(user:String)</h1><p>Get the profile of a specific user.</p>");
					var tiana = FB.getUser("raza.tiana");
					Lib.print("<h3>R.Tiana :</h3>");
					Lib.print("<img src='https://graph.facebook.com/raza.tiana/picture'> <br/> "+tiana.get('name'));  
					 
					Lib.print("<h1>FB.getUserFields(user:String, fields:Array<String>)</h1><p>Get specific fields of a user. eg: FB.getUserFields('raza.tiana', ['id', 'name'])</p>");
					var fields = FB.getUserFields("raza.tiana", ["id", "name"]);
					Lib.print("<br/><br/>"+fields.get('name')); 
					 
				}
      		}  
      }
